<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <!-- 
        v-model指令的作用是设置和获取表单元素的值
        绑定的数据会和表单元素值相关联
        绑定的数据———— 表单元素的值
     -->
    <script src="../js/vue.js"></script>

    <div id="root">
        <input type="text" v-model="message" @keyup.enter="getM">
        <input type="button" value="修改message" @click="setM">

        <h2> {{message}} </h2>
    </div>

    <script>
        var root = new Vue({
            el: "#root",
            data: {
                message: "黑马程序员",
            },
            methods: {
                getM() {
                    alert("触发点击getM事件" + this.message)
                },
                setM(){
                    this.message = "酷酷滴"
                }
            }
        })
    </script>

</body>

</html>